package socrates.movil;

import javax.crypto.spec.OAEPParameterSpec;

import org.h2.tools.ConvertTraceFile;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import socrates.ws.WSControler; 
import socrates.dto.AlumnoDTO;
import android.widget.*;
import socrates.movil.R.layout;

public class Inicio extends Activity
{
	private EditText edtuser;
	private EditText edtpass;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aute);	
        edtuser = (EditText)findViewById(R.id.txtuser);
		edtpass = (EditText)findViewById(R.id.txtpass);
    }
		
	public void autenticar(View view) {
			WSControler objc = new WSControler(0);
		
			AlumnoDTO alumno= new AlumnoDTO();	
			alumno = objc.obtener_Login(edtuser.getText().toString(), edtpass.getText().toString());
		
			       try{
			           if(alumno.getCod_Alumno()!=0)
			            {
			        	   String ab;
			        	   ab= String.valueOf(alumno.getCod_Alumno());
			           Intent i = new Intent(this, MenuP.class);
			           i.putExtra("codAlumno", String.valueOf(alumno.getCod_Alumno()));        
			           Inicio.this.finish();
		               startActivity(i);
			            }
			           else 
			           {
			            Toast.makeText(getApplicationContext(),
			           "Usuario o contrasena incorrecto", Toast.LENGTH_SHORT).show();
			           }
			           }
			          catch(Exception ex)
			          {
			           Toast.makeText(getApplicationContext(),
			          "Se produjo un error en la aplicacion", Toast.LENGTH_SHORT).show();
			          }

		}

	

	
}
